{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5836e666-3538-40da-8631-71b849e1764c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "850b69fb-04a5-4325-bffb-25bdac9498c6",
   "metadata": {},
   "source": [
    "## 1. 定义元组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ecce5531-f868-4e73-b490-8cdacaea63e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 3.14, 'abc', True)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(10, 3.14, 'abc', True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "427ed52b-6fd9-44d2-b0c4-74627f304eb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 3.14, 'abc', True)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "10, 3.14, 'abc', True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "be805d54-4f48-4646-a461-3c5ec1419c77",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6c62dfb8-078c-4be1-ab05-5645584287c5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "114b27da-8897-466b-8339-674251002149",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10,)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(10,)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "44de6e9b-a66c-4044-8c6e-78a3fd545798",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c880045a-a72f-4c9c-a8f8-1c7d4bfd9172",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "53f1c8bd-5537-4a1e-9147-a4895a401a13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 20, 30)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "10, 20, 30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9a720ce8-8647-4262-9339-dfd2c5d27128",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10,)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "10,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "57038c24-5e05-4a8a-8a59-115f30f3de97",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3aacf816-09d1-4114-b13d-b56ca91cb738",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t = 10, 11, 12, 13, 14\n",
    "t[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "decf5482-6a87-497d-8b2a-1392a5910c91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(14, 13, 12, 11, 10)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t = 10, 11, 12, 13, 14\n",
    "t[::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f3540c2b-1369-480c-a9d6-c4486fa2bf2b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 20, 30, 40, 50)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(10, 20, 30) + (40, 50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "26b382e0-f70e-4bac-be30-44fa25dd8e86",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 20, 70, 50)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "10, 20, 30 + 40, 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "784fc7b2-4083-48c9-9cd7-356771d44628",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t = 10, 20, 30, 40,\n",
    "20 in t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f7d88cff-a980-4b91-84c8-fb49b0346461",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a19e17e3-0aba-4599-aec4-24d850760b06",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'tuple' object does not support item assignment",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[14], line 2\u001b[0m\n\u001b[1;32m      1\u001b[0m t \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m, \u001b[38;5;241m11\u001b[39m, \u001b[38;5;241m12\u001b[39m, \u001b[38;5;241m13\u001b[39m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mt\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m\n",
      "\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
     ]
    }
   ],
   "source": [
    "t = 10, 11, 12, 13\n",
    "t[1] = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ca535f56-1426-4563-a810-c5d60db3261d",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'tuple' object doesn't support item deletion",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[15], line 2\u001b[0m\n\u001b[1;32m      1\u001b[0m t \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m, \u001b[38;5;241m11\u001b[39m, \u001b[38;5;241m12\u001b[39m, \u001b[38;5;241m13\u001b[39m\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m t[\u001b[38;5;241m1\u001b[39m]\n",
      "\u001b[0;31mTypeError\u001b[0m: 'tuple' object doesn't support item deletion"
     ]
    }
   ],
   "source": [
    "t = 10, 11, 12, 13\n",
    "del t[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e4eb4c2e-954b-4be8-8f3a-d02f59c7cd91",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "d7c7354a-bc02-4286-bdc7-0ec44d81f33a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{(201, '张三'): 1.71, (202, '李四'): 1.81}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "{(201, '张三'): 1.71, (202, '李四'): 1.81}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "2b66e4dd-d6ad-4ece-b3b2-0ded30ab7396",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unhashable type: 'list'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[17], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m {[\u001b[38;5;241m201\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m张三\u001b[39m\u001b[38;5;124m'\u001b[39m]: \u001b[38;5;241m1.71\u001b[39m, [\u001b[38;5;241m202\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m李四\u001b[39m\u001b[38;5;124m'\u001b[39m]: \u001b[38;5;241m1.81\u001b[39m}\n",
      "\u001b[0;31mTypeError\u001b[0m: unhashable type: 'list'"
     ]
    }
   ],
   "source": [
    "{[201, '张三']: 1.71, [202, '李四']: 1.81}"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
